package pl.edu.agh.mobicentsVoIP.utils;

import java.util.HashMap;
import java.util.Map;

public class Logger {

	private static Map<Class, Logger> class2log = null;
	private Class clazz;
	
	private Logger(Class clazz){
		this.clazz = clazz;
	}
	
	public static Logger getLogger(Class clazz){
		if(class2log == null){
			class2log = new HashMap<Class, Logger>();
		}
		Logger l = class2log.get(clazz);
		if(l == null){
			l = new Logger(clazz);
			class2log.put(clazz, l);
		}
		return l;
	}
	
	public void info(String log){
		System.out.println("[" + clazz.getSimpleName() + "]: "+ log);
	}
	
	public void error(String err){
		System.err.println("[" + clazz.getSimpleName() + "]: "+ err);
	}

	public void error(String err, Throwable e){
		System.err.println("[" + clazz.getSimpleName() + "]: "+ err);
		e.printStackTrace(System.err);
	}
}
